﻿using BCDto.Common.ErrorMessage;
using BCDto.TMS.WorkingReport;
using BCService.TMS.WorkingReport;
using BCTMSRESTful.Configs;
using Microsoft.AspNetCore.Mvc;
using System.Net;

namespace BCTMSRESTful.Controllers.DriverApp.WorkingReport
{
    /// <summary>
    /// 工作上报控制器
    /// </summary>
    [ApiExplorerSettings(GroupName = "DriverApp")]
    [Route("api/v1/DriverApp/[controller]")]
    public class WorkingReportsController : DriverAppBaseController
    {
        private readonly IWorkingReportService workingReportService;

        public WorkingReportsController(IWorkingReportService workingReportService)
        {
            this.workingReportService = workingReportService;
        }

        #region 创建一条工作上报信息
        /// <summary>
        /// 创建一条工作上报信息
        /// </summary>
        /// <param name="workingReportRequestDto">工作日报信息</param>
        /// <returns></returns>
        /// <response code="200">工作上报信息提交成功。</response>
        /// <response code="400">请求参数或输入的数据不正确。</response>
        /// <response code="401">请求需要认证或者认证信息已过期。</response>
        /// <response code="500">服务器内部错误。</response>
        [HttpPost]
        [Log("创建一条工作上报信息")]
        [ProducesResponseType(typeof(WorkingReportDto), 201)]
        [ProducesResponseType(typeof(ErrorMessageDto), 400)]
        [ProducesResponseType(typeof(ErrorMessageDto), 500)]
        public IActionResult Create([FromBody] WorkingReportRequestDto workingReportRequestDto)
        {
            var result = this.workingReportService.Add(this.Driver, workingReportRequestDto);
            return StatusCode((int)HttpStatusCode.Created, result);
        }
        #endregion


        #region 获取一条工作上报信息

        /// <summary>
        /// 获取工作上报信息
        /// </summary>
        /// <param name="workingReportId">工作上报信息Id</param>
        /// <returns></returns>
        /// <response code="200">查询工作上报信息成功。</response>
        /// <response code="400">请求参数或输入的数据不正确。</response>
        /// <response code="401">请求需要认证或者认证信息已过期。</response>
        /// <response code="500">服务器内部错误。</response>
        [HttpGet("{working_report_id}")]
        [ProducesResponseType(typeof(WorkingReportDto), 200)]
        public IActionResult Get([FromRoute(Name = "working_report_id")] long workingReportId)
        {
            return StatusCode((int)HttpStatusCode.OK, workingReportService.GetByWorkingReportId(workingReportId));
        }
        #endregion


    }
}
